<template>
  <div class="box">
    <div class="cont" v-for="item in contList" :key="item.month">
      <h3>{{ item.month }}</h3>
      <div
        class="cont-item"
        v-for="i in item.articles"
        :key="i.id"
        @click="openFun(i.id)"
      >
        <img :src="i.titleImage" alt="" />
        <div class="item-text">
          <p>{{ i.title }}</p>
          <span>
            <i class="el-icon-date"></i>
            {{ i.createTime }}</span
          >
        </div>
      </div>
    </div>
    <el-pagination
      @current-change="pageChange"
      :page-size="dataList.size"
      :current-page="dataList.current"
      layout="prev, pager, next"
      :total="dataList.total"
    >
    </el-pagination>
  </div>
</template>

<script>
import { Archive } from "../units/api.js";
export default {
  data() {
    return {
      dataList: {
        current: 1,
        size: 10,
        total:1,
      },
      contList: [],
    };
  },
  created() {
    this.getList();
  },
  methods: {
    async getList() {
      let res = await Archive(this.dataList);
      console.log("这是子组件获取到的归档", res);
      this.contList = res.data.data;
      this.dataList = res.data
    },
    openFun(id) {
      console.log(id);
      this.$router.push({ path: "detail", query: { articleId: id } });
    },
        pageChange(val) {
      // console.log(this.list.current);
      console.log(val);
      this.dataList.current = val;
      this.getList();
    },
  },
};
</script>

<style scoped>
.box {
  margin: 1vw;
  background-color: white;
  border-radius: 8px;
}
.cont-item {
  padding: 20px 0;
  margin: 0 45px;
  border-bottom: 1px solid #b5b5b5;
  display: flex;
}
.cont-item:hover {
  background-color: #f3f4f6;
}
.cont-item > img {
  width: 80px;
  height: 60px;
}
.item-text {
  padding-top: 5px;
  text-align: start;
  margin-left: 20px;
}
.item-text > p {
  margin-bottom: 10px;
}
.item-text > span {
  font-size: 14px;
  color: #b5b5b5;
}
</style>